/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pt.ua.miect.sd.simuladorpesca.config;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import pt.ua.miect.sd.simuladorpesca.conns.IMessageContent;

/**
 *
 * @author PedroA
 */
public class SimulationConfig implements Serializable, IMessageContent{

    private List<ServiceConfig> services;
    private int numOperators;
    private int boatsPerOperator;
    private int numFishSchool;
    private int mapXSize ;
    private int mapYSize ;
    private int maxShoalY;
    private long initialFishCount;
    private long minFishCount;
    private float ecoCoef;
    private float growthRate;
    private int portHomeX;
    private int portHomeY;
    private int fishMoveRatio;
    private int sprowningSeasonLenght;
    private int fishingSeasonLenght;
    private int maxBoatCapacity;
    private int maxWait;
    private int timeout;

    public SimulationConfig() {
        services = new ArrayList<ServiceConfig>();
        numOperators = 5;
        boatsPerOperator = 5;
        numFishSchool = 5;
        mapXSize = 11;
        mapYSize = 11;
        maxShoalY = 2;
        initialFishCount = 2000;
        minFishCount = 30;
        ecoCoef = 0.001f;
        growthRate = 2.01f;
        portHomeX = 0;
        portHomeY = 0;
        fishMoveRatio = 2;
        sprowningSeasonLenght = 40;
        fishingSeasonLenght = 100;
        maxBoatCapacity = 100;
        maxWait = 10;
        timeout = 60000;
    }

    /**
     * 
     * @return the services
     */
    public List<ServiceConfig> getServices() {
        return services;
    }

    /**
     * @param services the services to set
     */
    public void setServices(List<ServiceConfig> services) {
        this.services = services;
    }

    /**
     * @return the numOperators
     */
    public int getNumOperators() {
        return numOperators;
    }

    /**
     * @param numOperators the numOperators to set
     */
    public void setNumOperators(int numOperators) {
        this.numOperators = numOperators;
    }

    /**
     * @return the boatsPerOperator
     */
    public int getBoatsPerOperator() {
        return boatsPerOperator;
    }

    /**
     * @param boatsPerOperator the boatsPerOperator to set
     */
    public void setBoatsPerOperator(int boatsPerOperator) {
        this.boatsPerOperator = boatsPerOperator;
    }

    /**
     * @return the numFishSchool
     */
    public int getNumFishSchool() {
        return numFishSchool;
    }

    /**
     * @param numFishSchool the numFishSchool to set
     */
    public void setNumFishSchool(int numFishSchool) {
        this.numFishSchool = numFishSchool;
    }

    /**
     * @return the mapXSize
     */
    public int getMapXSize() {
        return mapXSize;
    }

    /**
     * @param mapXSize the mapXSize to set
     */
    public void setMapXSize(int mapXSize) {
        this.mapXSize = mapXSize;
    }

    /**
     * @return the mapYSize
     */
    public int getMapYSize() {
        return mapYSize;
    }

    /**
     * @param mapYSize the mapYSize to set
     */
    public void setMapYSize(int mapYSize) {
        this.mapYSize = mapYSize;
    }

    /**
     * @return the maxShoalY
     */
    public int getMaxShoalY() {
        return maxShoalY;
    }

    /**
     * @param maxShoalY the maxShoalY to set
     */
    public void setMaxShoalY(int maxShoalY) {
        this.maxShoalY = maxShoalY;
    }

    /**
     * @return the initialFishCount
     */
    public long getInitialFishCount() {
        return initialFishCount;
    }

    /**
     * @param initialFishCount the initialFishCount to set
     */
    public void setInitialFishCount(long initialFishCount) {
        this.initialFishCount = initialFishCount;
    }

    /**
     * @return the minFishCount
     */
    public long getMinFishCount() {
        return minFishCount;
    }

    /**
     * @param minFishCount the minFishCount to set
     */
    public void setMinFishCount(long minFishCount) {
        this.minFishCount = minFishCount;
    }

    /**
     * @return the ecoCoef
     */
    public float getEcoCoef() {
        return ecoCoef;
    }

    /**
     * @param ecoCoef the ecoCoef to set
     */
    public void setEcoCoef(float ecoCoef) {
        this.ecoCoef = ecoCoef;
    }

    /**
     * @return the growthRate
     */
    public float getGrowthRate() {
        return growthRate;
    }

    /**
     * @param growthRate the growthRate to set
     */
    public void setGrowthRate(float growthRate) {
        this.growthRate = growthRate;
    }

    /**
     * @return the portHomeX
     */
    public int getPortHomeX() {
        return portHomeX;
    }

    /**
     * @param portHomeX the portHomeX to set
     */
    public void setPortHomeX(int portHomeX) {
        this.portHomeX = portHomeX;
    }

    /**
     * @return the portHomeY
     */
    public int getPortHomeY() {
        return portHomeY;
    }

    /**
     * @param portHomeY the portHomeY to set
     */
    public void setPortHomeY(int portHomeY) {
        this.portHomeY = portHomeY;
    }

    /**
     * @return the fishMoveRatio
     */
    public int getFishMoveRatio() {
        return fishMoveRatio;
    }

    /**
     * @param fishMoveRatio the fishMoveRatio to set
     */
    public void setFishMoveRatio(int fishMoveRatio) {
        this.fishMoveRatio = fishMoveRatio;
    }

    /**
     * @return the sprowningSeasonLenght
     */
    public int getSprowningSeasonLenght() {
        return sprowningSeasonLenght;
    }

    /**
     * @param sprowningSeasonLenght the sprowningSeasonLenght to set
     */
    public void setSprowningSeasonLenght(int sprowningSeasonLenght) {
        this.sprowningSeasonLenght = sprowningSeasonLenght;
    }

    /**
     * @return the fishingSeasonLenght
     */
    public int getFishingSeasonLenght() {
        return fishingSeasonLenght;
    }

    /**
     * @param fishingSeasonLenght the fishingSeasonLenght to set
     */
    public void setFishingSeasonLenght(int fishingSeasonLenght) {
        this.fishingSeasonLenght = fishingSeasonLenght;
    }

    /**
     * @return the maxBoatCapacity
     */
    public int getMaxBoatCapacity() {
        return maxBoatCapacity;
    }

    /**
     * @param maxBoatCapacity the maxBoatCapacity to set
     */
    public void setMaxBoatCapacity(int maxBoatCapacity) {
        this.maxBoatCapacity = maxBoatCapacity;
    }

    /**
     * @return the maxWait
     */
    public int getMaxWait() {
        return maxWait;
    }

    /**
     * @param maxWait the maxWait to set
     */
    public void setMaxWait(int maxWait) {
        this.maxWait = maxWait;
    }

    /**
     * @return the timeout
     */
    public int getTimeout() {
        return timeout;
    }

    /**
     * @param timeout the timeout to set
     */
    public void setTimeout(int timeout) {
        this.timeout = timeout;
    }

    /**
     * Gets a serviceConfig for a given ip&port
     * @param ip
     * @param port
     * @return
     */
    public ServiceConfig getService(String ip, int port)
    {
        for (ServiceConfig sc : services) {
            if (Pattern.matches(ip, sc.getIpAddress()) && sc.getPort()== port)
            {
                return sc;
            }
        }
        return null;
    }
}
